package com.menu.web.controller.reception;

import com.menu.common.annotation.Log;
import com.menu.common.core.controller.BaseController;
import com.menu.common.core.domain.AjaxResult;
import com.menu.common.core.page.TableDataInfo;
import com.menu.common.enums.BusinessType;
import com.menu.common.utils.poi.ExcelUtil;
import com.menu.system.domain.ReceptionMenu;
import com.menu.system.service.IreceptionMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 前台菜单权限Controller
 *
 * @author ruoyi
 * @date 2024-06-06
 */
@RestController
@RequestMapping("/system/receptionMenu")
public class receptionMenuController extends BaseController {
    @Autowired
    private IreceptionMenuService receptionMenuService;

    /**
     * 查询前台菜单权限列表
     */
    @PreAuthorize("@ss.hasPermi('system:receptionMenu:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReceptionMenu receptionMenu) {
        startPage();
        List<ReceptionMenu> list = receptionMenuService.selectreceptionMenuList(receptionMenu);
        return getDataTable(list);
    }

    /**
     * 导出前台菜单权限列表
     */
    @PreAuthorize("@ss.hasPermi('system:receptionMenu:export')")
    @Log(title = "前台菜单权限", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReceptionMenu receptionMenu) {
        List<ReceptionMenu> list = receptionMenuService.selectreceptionMenuList(receptionMenu);
        ExcelUtil<ReceptionMenu> util = new ExcelUtil<ReceptionMenu>(ReceptionMenu.class);
        util.exportExcel(response, list, "前台菜单权限数据");
    }

    /**
     * 获取前台菜单权限详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:receptionMenu:query')")
    @GetMapping(value = "/{menuId}")
    public AjaxResult getInfo(@PathVariable("menuId") Long menuId) {
        return success(receptionMenuService.selectreceptionMenuByMenuId(menuId));
    }

    /**
     * 新增前台菜单权限
     */
    @PreAuthorize("@ss.hasPermi('system:receptionMenu:add')")
    @Log(title = "前台菜单权限", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReceptionMenu receptionMenu) {
        return toAjax(receptionMenuService.insertreceptionMenu(receptionMenu));
    }

    /**
     * 修改前台菜单权限
     */
    @PreAuthorize("@ss.hasPermi('system:receptionMenu:edit')")
    @Log(title = "前台菜单权限", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReceptionMenu receptionMenu) {
        return toAjax(receptionMenuService.updatereceptionMenu(receptionMenu));
    }

    /**
     * 删除前台菜单权限
     */
    @PreAuthorize("@ss.hasPermi('system:receptionMenu:remove')")
    @Log(title = "前台菜单权限", businessType = BusinessType.DELETE)
    @DeleteMapping("/{menuIds}")
    public AjaxResult remove(@PathVariable Long[] menuIds) {
        return toAjax(receptionMenuService.deletereceptionMenuByMenuIds(menuIds));
    }
}
